# -*- coding: utf-8 -*-
#自定义日志模块用来记录日志
import time
import re

from userlog.function import SaveUserlog


class SimpleMiddleware(object):
    def __init__(self, get_response):
        self.get_response = get_response
        # One-time configuration and initialization.

    def process_view(self,request, view_func, view_args, view_kwargs):
        cls = SaveUserlog()
        cls(request)

    #
    # def process_exception(self,request, exception):
    #     print exception


    def __call__(self, request):
        # Code to be executed for each request before
        # the view (and later middleware) are called.

        response = self.get_response(request)

        # Code to be executed for each request/response after
        # the view is called.
         # 保存日志记录

        return response


